package com.oJudge.service.impl;

import com.oJudge.service.COSService;
import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.region.Region;
import org.springframework.beans.factory.annotation.Value;


public class COSServiceImpl implements COSService {
    @Value("${cos.client.accessKey}")
    private static String secretId;
    @Value("${cos.client.secretKey}")
    private static String secretKey;

    public static COSClient getClient() {
        // 初始化用户身份信息(secretId, secretKey)
        System.out.println("secretId" + secretId);
        COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
        // 设置bucket的区域, COS地域的简称请参照 https://www.qcloud.com/document/product/436/6224
        ClientConfig clientConfig = new ClientConfig(new Region("ap-guangzhou"));
        // 生成cos客户端
        return new COSClient(cred, clientConfig);
    }
}